<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

<title>Plupload - Custom example</title>

<!-- production -->
<script type="text/javascript" src="../HRTWEB/plupload/plupload.full.min.js"></script>

</head>
<body style="font: 13px Verdana; background: #eee; color: #333">

<h1>文件上传测试</h1>

<p>文件列表</p>
<table style="width: 600px" id="uploadTable" border="1">
		<tr>
			<td>文件类型</td>
			<td>文件名称</td>
			<td>操作</td>
			<td>上传进度</td>
		</tr>
	</table>
<div id="filelist">Your browser doesn't have Flash, Silverlight or HTML5 support.</div>
<br />

<div id="container">
    <a id="pickfiles" href="javascript:;">[选择文件]</a> 
    <a id="uploadfiles" href="javascript:;">[上传文件]</a>
</div>

<br />
<pre id="console"></pre>


<script type="text/javascript">
// Custom example logic

var uploader = new plupload.Uploader({
	runtimes : 'html5,flash,silverlight,html4',
	browse_button : 'pickfiles', // you can pass in id...
	container: document.getElementById('container'), // ... or DOM Element itself
	url : './uploadtest.do',
	flash_swf_url : '../js/Moxie.swf',
	silverlight_xap_url : '../js/Moxie.xap',
	
	filters : {
		max_file_size : '10mb',
		mime_types: [
			{title : "Image files", extensions : "jpg,gif,png"},
			{title : "Zip files", extensions : "zip"}
		]
	},

	init: {
		PostInit: function() {
			document.getElementById('filelist').innerHTML = '';

			document.getElementById('uploadfiles').onclick = function() {
				uploader.start();
				return false;
			};
		},
		BeforeUpload : function(up, file) {
			alert(file.name);
			up.settings.url = encodeURI("./uploadtest.do?" + "name="+ file.name+"&type="+file.type+"&size="+file.size);

		},
		FilesAdded: function(up, files) {
			plupload.each(files, function(file) {
				document.getElementById('uploadTable').innerHTML += "<tr id='"+file.id+"'><td>"+file.type+"</td><td>"+file.name+"</td><td><button type='button' id='"+file.id+"btn' onclick=del('"+file.id+"')>删除</button> </td><td id='"+file.id+"'></td></tr>";
			});
		},

		UploadProgress: function(up, file) {
			document.getElementById(file.id).getElementsByTagName('td')[3].innerHTML = '<td>' + file.percent + "%</td>";
		},
		UploadComplete : function(uploader, files) {

			alert("上传完毕");
		},
		FileUploaded : function(up, file) {
			alert("文件上传成功");
			up.settings.url = "";
		},
		Error: function(up, err) {
			document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
		}
	}
});

uploader.init();

</script>
</body>
</html>
